<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
test(() => assert_selection(
    [
        '<div contenteditable>',
            'abc<img src="../resources/abe.png"> <img src="../resources/abe.png">| def<br>',
            'ghi<img src="../resources/abe.png">',
        '</div>',
    ].join(''),
    'delete',
    [
        '<div contenteditable>',
            'abc<img src="../resources/abe.png"> |\u{00A0}def<br>',
            'ghi<img src="../resources/abe.png">',
        '</div>',
    ].join('')),
    '1 Delete image before caret with a space');

test(() => assert_selection(
    [
        '<div contenteditable>',
            'abc<img src="../resources/abe.png">|def<br>',
        '</div>',
    ].join(''),
    'delete',
    [
        '<div contenteditable>',
            'abc|def<br>',
        '</div>',
    ].join('')),
    '2 Delete image before caret');

test(() => assert_selection(
    [
        '<div contenteditable>',
            'abc^<img src="../resources/abe.png"><img src="../resources/abe.png">| def',
        '</div>',
    ].join(''),
    'delete',
    [
        '<div contenteditable>',
            'abc|\u{00A0}def',
        '</div>',
    ].join('')),
    '3 Delete images between text');

test(() => assert_selection(
    [
        '<div contenteditable>',
            '^<img src="../resources/abe.png"><img src="../resources/abe.png">|',
        '</div>',
    ].join(''),
    'delete',
    '<div contenteditable>|</div>'),
    '4 Delete images');
</script>
